package pe.edu.pucp.notasmoviles.aop;

import org.apache.log4j.Logger;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

@Component
@Aspect
// Aspecto: Clase Java que implementa un cross-cutting concern
public class LoggingAspect {

	private Logger logger = Logger.getLogger(LoggingAspect.class);

	@Before("pe.edu.pucp.notasmoviles.aop.SystemArchitecture.servicePointcut()")
	public void beforeService() {
		logger.debug("Interceptando: beforeService");
	}

	@After("pe.edu.pucp.notasmoviles.aop.SystemArchitecture.servicePointcut()")
	public void afterService() {
		logger.debug("Interceptando: afterService");
	}
	
	@AfterReturning("pe.edu.pucp.notasmoviles.aop.SystemArchitecture.servicePointcut()")
	public void afterReturningService() {
		logger.debug("Interceptando: afterReturningService");
	}
	
	@AfterThrowing("pe.edu.pucp.notasmoviles.aop.SystemArchitecture.servicePointcut()")
	public void afterThrowingService() {
		logger.debug("Interceptando: afterThrowingService");
	}

	@Before(("pe.edu.pucp.notasmoviles.aop.SystemArchitecture.daoPointcut()"))
	public void beforeDao() {
		logger.debug("Interceptando: beforeDao");
	}

	@After("pe.edu.pucp.notasmoviles.aop.SystemArchitecture.daoPointcut()")
	public void afterDao() {
		logger.debug("Interceptando: afterDao");
	}

}
